package admin

import (
	"grpc.getaway.adminspro.padmins.com/internal/api/module/admin/container"
	"grpc.getaway.adminspro.padmins.com/internal/api/utils/rpc"
	"grpc.getaway.adminspro.padmins.com/pkg/businessCommonQuery"
	pbAdmin "grpc.getaway.adminspro.padmins.com/pkg/proto/admin"
)

func Index(c *container.Context) (interface{}, error) {
	BusinessCommonQuery, e := businessCommonQuery.BuildByRequest(c.Request)
	if e != nil {
		return nil, e
	}

	req := &pbAdmin.AdminIndexReq{
		BusinessCommonQuery: BusinessCommonQuery,
		OperaterId:          c.Auth.Data.Admin.Id,
		ShowTotal:           true,
	}

	return rpc.GetAdminClient().AdminIndex(c.GetContext(), req)
}
